package com.siao.component
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	
	/**
	 * 基于影片剪辑的八态复选框
	 * @author SiaoLeon
	 */
	public class CheckBoxClip extends CheckBox
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		override public function set content(value:DisplayObject):void
		{
			super.content = value;
			
			this.enabled = true;
		}
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 * @param clip
		 * 八帧的按钮影片剪辑，八帧分别为八种状态：选中常态、选中划过、选中按下、选中不可用、未选中常态、未选中划过、未选中按下、未选中不可用
		 */
		public function CheckBoxClip(clip:MovieClip)
		{
			super();
			
			this.content = clip;
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		// -------------------------------------------------------------------------------------------------------- 函数
		
		override protected function onNormal():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop((this.selected) ? 1 : 5);
			}
		}
		
		override protected function onMouseOver():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop((this.selected) ? 2 : 6);
			}
		}
		
		override protected function onMouseDown():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop((this.selected) ? 3 : 7);
			}
		}
		
		override protected function onDisabled():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop((this.selected) ? 4 : 8);
			}
		}
	
	}
}
